﻿using IniReadWrite;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VisionRoc.Core
{
    public class SystemYield
    {
        public string YieldPath;

        public SystemYield(string _Path)
        {
            //判断文件路径是否存在
            if (!Directory.Exists(_Path))
            {
                Directory.CreateDirectory(_Path);
            }
            YieldPath = _Path + "\\Yield.ini";
            if (File.Exists(YieldPath))
            {
                ReadPar();
            }
        }



        /// <summary>
        /// Camera1 总数据
        /// </summary>
        public double CameraAll1 { get; set; } = 0;

        /// <summary>
        /// Camera1 OK数据
        /// </summary>
        public double CameraOK1 { get; set; } = 0;

        /// <summary>
        /// Cmera1 NG数据
        /// </summary>
        public double CameraNG1 { get; set; } = 0;

        /// <summary>
        /// Camera1 良率数据
        /// </summary>
        public string CameraYield1 { get; set; } = "0.00%";


        /// <summary>
        /// Camera2 总数据
        /// </summary>
        public double CameraAll2 { get; set; } = 0;

        /// <summary>
        /// Camera2 OK数据
        /// </summary>
        public double CameraOK2 { get; set; } = 0;

        /// <summary>
        /// Cmera2 NG数据
        /// </summary>
        public double CameraNG2 { get; set; } = 0;

        /// <summary>
        /// Camera3 良率数据
        /// </summary>
        public string CameraYield2 { get; set; } = "0.00%";




        /// <summary>
        /// Camera3 总数据
        /// </summary>
        public double CameraAll3 { get; set; } = 0;

        /// <summary>
        /// Camera3 OK数据
        /// </summary>
        public double CameraOK3 { get; set; } = 0;

        /// <summary>
        /// Cmera3 NG数据
        /// </summary>
        public double CameraNG3 { get; set; } = 0;

        /// <summary>
        /// Camera3 良率数据
        /// </summary>
        public string CameraYield3 { get; set; } = "0.00%";



        /// <summary>
        /// Camera4 总数据
        /// </summary>
        public double CameraAll4 { get; set; } = 0;

        /// <summary>
        /// Camera4 OK数据
        /// </summary>
        public double CameraOK4 { get; set; } = 0;

        /// <summary>
        /// Cmera4 NG数据
        /// </summary>
        public double CameraNG4 { get; set; } = 0;

        /// <summary>
        /// Camera4良率数据
        /// </summary>
        public string CameraYield4 { get; set; } = "0.00%";



        /// <summary>
        /// Camera5 总数据
        /// </summary>
        public double CameraAll5 { get; set; } = 0;

        /// <summary>
        /// Camera5OK数据
        /// </summary>
        public double CameraOK5 { get; set; } = 0;

        /// <summary>
        /// Cmera5NG数据
        /// </summary>
        public double CameraNG5 { get; set; } = 0;

        /// <summary>
        /// Camera5 良率数据
        /// </summary>
        public string CameraYield5 { get; set; } = "0.00%";






        public void WritePar()
        {
            IniAPI.INIWriteValue(YieldPath, "Yield", "CameraAll1", CameraAll1.ToString());
            IniAPI.INIWriteValue(YieldPath, "Yield", "CameraOK1", CameraOK1.ToString());
            IniAPI.INIWriteValue(YieldPath, "Yield", "CameraNG1", CameraNG1.ToString());
            IniAPI.INIWriteValue(YieldPath, "Yield", "CameraYield1", CameraYield1.ToString());

            IniAPI.INIWriteValue(YieldPath, "Yield", "CameraAll2", CameraAll2.ToString());
            IniAPI.INIWriteValue(YieldPath, "Yield", "CameraOK2", CameraOK2.ToString());
            IniAPI.INIWriteValue(YieldPath, "Yield", "CameraNG2", CameraNG2.ToString());
            IniAPI.INIWriteValue(YieldPath, "Yield", "CameraYield2", CameraYield2.ToString());

            IniAPI.INIWriteValue(YieldPath, "Yield", "CameraAll3", CameraAll3.ToString());
            IniAPI.INIWriteValue(YieldPath, "Yield", "CameraOK3", CameraOK3.ToString());
            IniAPI.INIWriteValue(YieldPath, "Yield", "CameraNG3", CameraNG3.ToString());
            IniAPI.INIWriteValue(YieldPath, "Yield", "CameraYield3", CameraYield3.ToString());

            IniAPI.INIWriteValue(YieldPath, "Yield", "CameraAll4", CameraAll4.ToString());
            IniAPI.INIWriteValue(YieldPath, "Yield", "CameraOK4", CameraOK4.ToString());
            IniAPI.INIWriteValue(YieldPath, "Yield", "CameraNG4", CameraNG4.ToString());
            IniAPI.INIWriteValue(YieldPath, "Yield", "CameraYield4", CameraYield4.ToString());

            IniAPI.INIWriteValue(YieldPath, "Yield", "CameraAll5", CameraAll5.ToString());
            IniAPI.INIWriteValue(YieldPath, "Yield", "CameraOK5", CameraOK5.ToString());
            IniAPI.INIWriteValue(YieldPath, "Yield", "CameraNG5", CameraNG5.ToString());
            IniAPI.INIWriteValue(YieldPath, "Yield", "CameraYield5", CameraYield5.ToString());
        }

        public void ReadPar()
        {
            CameraAll1 = Convert.ToInt32(IniAPI.INIGetStringValue(YieldPath, "Yield", "CameraAll1", "0"));
            CameraOK1 = Convert.ToInt32(IniAPI.INIGetStringValue(YieldPath, "Yield", "CameraOK1", "0"));
            CameraNG1 = Convert.ToInt32(IniAPI.INIGetStringValue(YieldPath, "Yield", "CameraNG1", "0"));
            CameraYield1 = IniAPI.INIGetStringValue(YieldPath, "Yield", "CameraYield1", "0");

            CameraAll2 = Convert.ToInt32(IniAPI.INIGetStringValue(YieldPath, "Yield", "CameraAll2", "0"));
            CameraOK2 = Convert.ToInt32(IniAPI.INIGetStringValue(YieldPath, "Yield", "CameraOK2", "0"));
            CameraNG2 = Convert.ToInt32(IniAPI.INIGetStringValue(YieldPath, "Yield", "CameraNG2", "0"));
            CameraYield2 = IniAPI.INIGetStringValue(YieldPath, "Yield", "CameraYield2", "0");

            CameraAll3 = Convert.ToInt32(IniAPI.INIGetStringValue(YieldPath, "Yield", "CameraAll3", "0"));
            CameraOK3 = Convert.ToInt32(IniAPI.INIGetStringValue(YieldPath, "Yield", "CameraOK3", "0"));
            CameraNG3 = Convert.ToInt32(IniAPI.INIGetStringValue(YieldPath, "Yield", "CameraNG3", "0"));
            CameraYield3 = IniAPI.INIGetStringValue(YieldPath, "Yield", "CameraYield3", "0");

            CameraAll4 = Convert.ToInt32(IniAPI.INIGetStringValue(YieldPath, "Yield", "CameraAll4", "0"));
            CameraOK4 = Convert.ToInt32(IniAPI.INIGetStringValue(YieldPath, "Yield", "CameraOK4", "0"));
            CameraNG4 = Convert.ToInt32(IniAPI.INIGetStringValue(YieldPath, "Yield", "CameraNG4", "0"));
            CameraYield4 = IniAPI.INIGetStringValue(YieldPath, "Yield", "CameraYield4", "0");

            CameraAll5 = Convert.ToInt32(IniAPI.INIGetStringValue(YieldPath, "Yield", "CameraAll5", "0"));
            CameraOK5 = Convert.ToInt32(IniAPI.INIGetStringValue(YieldPath, "Yield", "CameraOK5", "0"));
            CameraNG5 = Convert.ToInt32(IniAPI.INIGetStringValue(YieldPath, "Yield", "CameraNG5", "0"));
            CameraYield5 = IniAPI.INIGetStringValue(YieldPath, "Yield", "CameraYield5", "0");
        }

    }
}
